<template>
	<!-- 商铺管理 -->
	<view class="s_wp">
		<view class="s_item" v-for="(item,index) in list" :key="item.uid"
			@click="$navTo('/pages/groupmenu/shopset?uid='+item.uid)">
			<image :src="item.logo" mode=""></image>
			<view class="s_info">
				<view class="s_li">
					<text class="clamp">{{item.supname}}</text>
					<text class="s_status">{{item.status}}</text>
				</view>
				<view class="s_li">
					<text>负责人：{{item.nickname}}</text>
					<text class="s_delete" @click.stop="deleteTap($event,index)">删除</text>
				</view>
			</view>
		</view>
		<view class="r_empty" v-if="list.length<=0">空空如也~</view>
		<view class="s_add" @click="$navTo('/pages/groupmenu/addshop')">添加店铺</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
			}
		},
		onBackPress(e) {
			if (e.from == "backbutton") {
				this.$navBack(2);
				return true;
			}
		},
		onLoad() {
			this.getlist();
		},
		methods: {
			deleteTap(e, i) {
				e.stopPropagation();
				uni.showLoading({
					title: '删除中'
				})
				this.$axios('groupManager/delGroupSup', 'POST', 'supplier', {
					uid: this.list[i].uid
				}).then(res => {
					uni.hideLoading();
					if (res.data.code == 200) {
						this.list.splice(i, 1);
						this.$api.msg('删除成功！');
					}
				})

			},
			getlist() {
				this.$axios('groupManager/suplist', 'POST', 'supplier').then(res => {
					if (res.data.code == 200) {
						this.list = res.data.data;
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		color: $font-color-dark;
		padding-bottom: 130upx;
		background-color: #f2f2f2;
	}

	.s_wp {
		overflow: hidden;
	}

	.s_item {
		background-color: #fff;
		display: flex;
		line-height: 50upx;
		padding: 20upx;
		margin-top: 20upx;
		position: relative;
	}

	.s_item image {
		border-radius: 10upx;
		height: 100upx;
		width: 100upx;
	}

	.s_info {
		flex: 1;
		padding: 0 20upx;
	}

	.s_li {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.s_li text:nth-of-type(2) {
		line-height: 50upx;
		text-align: center;
		width: 100upx;
	}

	.s_status {
		color: #FF0000;
	}

	.s_li .s_delete {
		background-color: #FF0000;
		border-radius: 10upx;
		color: #fff;
	}

	.r_empty {
		color: $font-color-spec;
		text-align: center;
		margin: 40upx;
	}

	.s_add {
		background-color: $base-color;
		border-radius: 40upx;
		color: #fff;
		position: fixed;
		left: 3%;
		bottom: 40upx;
		line-height: 80upx;
		text-align: center;
		width: 94%;
	}
</style>
